import time

import allure
from selenium.webdriver.common.by import By

from exercise2.page_frame.base_all import BaseAll


class Home_page(BaseAll):
    _CLICK_INPUT = By.CSS_SELECTOR, "#search-button"
    _INPUT = By.ID, "search-term"
    _CLICK_SEARCH = By.CSS_SELECTOR, ".show-advanced-search"

    @allure.step("输入信息并点击高级搜索")
    def search(self, value1):
        self.open_url("https://ceshiren.com/")
        self.find_ele(*self._CLICK_INPUT).click()
        # 输入关键字
        time.sleep(2)
        self.find_ele(*self._INPUT).send_keys(value1)
        # 点击高级搜索
        self.wait_locate(*self._CLICK_SEARCH)
        self.find_ele(*self._CLICK_SEARCH).click()
        from exercise2.page_frame.senior_page import SeniorPage
        return SeniorPage(self.driver)
